#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
void Reserve_ticket(){}
void Cancel_ticket(){}
void Passenger_info(){}

typedef struct
{
int dd;char m[5];int yr;
}date;

typedef struct
{ int hr;char a;int min;char d[3];
}time;

typedef struct
{
int no; char s[2];
}s_no;

typedef struct
{
char destination[20];
int Bus1_no;time dept_time;
int Bus2_no;time deptt_time;
int price;
}info;

typedef struct
{
char name[30];
char destination[20];
date rsrvtn_date;
date dept_date;
time dept_time;
s_no seat;
int price;
}pass_info;

void main()
{
    int a;
    a=main_menu();
    switch(a)
    {
       case 1:
         Route_info();break;
       case 2:
         Reserve_ticket();break;
       case 3:
         Cancel_ticket();break;
       case 4:
         Passenger_info();break;
       default:
          help();
    }
}


help()
{
    printf("\n If you are new to this system please make sure that the file named 'Bus info' currently exists in your system\n");
    printf("\n Bus info should contain all the information regarding bus");
    printf("\nFor any inconvenience please contact the developers\n\n");
}


int main_menu()
{
    int choice;
    printf("\n\n\t\t\tWELCOME TO THE TICKET RESERVATION SYSTEM \n\n\n");
    printf(" Please enter what do you want to do : \n\n");
    printf(" 1.Route info\n 2.Reserve ticket\n 3.Cancel ticket\n 4.Passenger info\n 5.Any help regarding this system\n\n");
    scanf("%d",&choice);
    return choice;
}


void Route_info()
{
char arr[10];
    FILE *new_file;
    new_file=fopen("bus info.txt","r+");
    if(new_file==NULL)
    {
        printf("\n The file cannot be opened\n");
        printf("\n Please make sure that the file you tried to open currently exists in your system.\n");
    }
    else
    {
        printf("\n Your file has been successfully opened for reading.\n\n");


       while(!EOF)
        {
            fscanf(new_file,"%s%d%d%c%d%s%d%d%c%d%s%d",&info.destination,&info.Bus1_no,&info.dept_time.hr,&info.dept_time.a,&info.dept_time.min,&info.dept_time.char,&info.Bus2_no,&info.deptt_time.hr,&info.deptt_time.a,&info.deptt_time.min,&info.deptt_time.char,&info.price);
            printf("\n\ndestination:  %s\n",info.destination);
            printf("Bus no: %d\nTime:  %d%c%d%s\n",info.Bus1_no,info.dept_time.hr,info.dept_time.a,info.dept_time.min,info.dept_time.char);
            printf("Bus no: %d\nTime:  %d%c%d%s\n",info.Bus2_no,info.deptt_time.hr,info.deptt_time.a,info.deptt_time.min,info.time.char);
            printf("price:  %d",info.price);
        }
    fclose(new_file);
    }
}

